﻿<%@page pageEncoding="utf-8" %>
<%@include file="/util/tag.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <%@include file="../common/head.jsp"%>
    <script language="javascript" type="text/javascript">
              //显示角色详细信息
            function showDetail(flag, a) {
                var detailDiv = a.parentNode.getElementsByTagName("div")[0];
                if (flag) {
                    detailDiv.style.display = "block";
                }
                else
                    detailDiv.style.display = "none";
            }
            //重置密码
            function resetPwd() {
            	var chkboxes = $(":checkbox:checked");
            	if(chkboxes.length==0){
                alert("请至少选择一条数据！");
                return;
                }
                 var r = window.confirm("确定要对选中管理员密码重置吗？");
                 if(!r)	return;
                var b = chkboxes.submitForm('reset_pwd','密码重置失败！数据并发错误。',
                														"密码重置成功！",$("#operate_msg"));
                if(b){
                	$("#operate_result_info").attr("class","operate_success");
                }
                document.getElementById("operate_result_info").style.display = "block";
            }
            //删除
            function deleteAdmin(id) {
                var r = window.confirm("确定要删除此管理员吗？");
                if(!r)	return;
                var b = request('delete?id='+id,'删除成功！',
                														"删除失败！数据并发错误。",$("#operate_msg"));
                if(b){
                	$("#operate_result_info").attr("class","operate_success");
                }
             			document.getElementById("operate_result_info").style.display = "block";
            }
            //全选
            function selectAdmins(inputObj) {
                var inputArray = document.getElementById("datalist").getElementsByTagName("input");
                for (var i = 1; i < inputArray.length; i++) {
                    if (inputArray[i].type == "checkbox") {
                        inputArray[i].checked = inputObj.checked;
                    }
                }
            }
            //搜索
            function search(){
            	location="list?"+$("#selModules").serialize()+'&'+
            	$('#roleName').serialize();
            }
    </script>
           
    <body>
        <%@include file="../common/top.jsp"%>
        
        <div id="main">
           	<s:form theme="simple">
                <!--查询-->
                <div class="search_add">
                    <div>
                        模块：
                        <s:select list="moduleOptions" name="module" id="selModules" cssClass="select_search"/>
                    </div>
                    <div>角色：<input type="text" name="roleName" value="${roleName}"id="roleName" class="text_search width200" /></div>
                    <div><input type="button" value="搜索" class="btn_search" onclick="search()"/></div>
                    <input type="button" value="密码重置" class="btn_add" onclick="resetPwd();" />
                    <input type="button" value="增加" class="btn_add" onclick="location.href='toAdd?module=${module }&roleName=${roleName }&';" />
                </div>
                <!--删除和密码重置的操作提示-->
                <div id="operate_result_info" class="operate_fail">
                    <img src="../images/close.png" onclick="this.parentNode.style.display='none';location.reload();" />
                    <span id="operate_msg">删除失败！数据并发错误。</span><!--密码重置失败！数据并发错误。-->
                </div> 
                <!--数据区域：用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                        <tr>
                            <th class="th_select_all">
                                <input type="checkbox" onclick="selectAdmins(this);" />
                                <span>全选</span>
                            </th>
                            <th>管理员ID</th>
                            <th>姓名</th>
                            <th>登录名</th>
                            <th>电话</th>
                            <th>电子邮件</th>
                            <th>授权日期</th>
                            <th class="width100">拥有角色</th>
                            <th></th>
                        </tr>      
                     <s:iterator value="adminList">               
                        <tr>
                            <td><input type="checkbox" name="adminId" value="${id}"/></td>
                            <td>${id}</td>
                            <td>${name}</td>
                            <td>${code}</td>
                            <td>${telephone}</td>
                            <td>${email}</td>
                            <td><s:date name="enrollDate" format="yyyy-MM-dd"/></td>
                            <td>
                                <a class="summary"  onmouseover="showDetail(true,this);" onmouseout="showDetail(false,this);"><s:property value="roles.toArray()[0].name"/><s:if test="roles.size()>1">...</s:if></a>
                                <!--浮动的详细信息--><s:if test="roles.size()>1">
                                <div class="detail_info">
                                <s:property value="roles.toArray()[0].name"/>
                                <s:iterator value="roles.toArray()" begin="1">
                                		<s:property value="','+name"/>
                                </s:iterator>
                                </div>
                               </s:if>
                            </td>
                            <td class="td_modi">
                                <input type="button" value="修改" class="btn_modify" onclick="location.href='toUpdate?module=${module }&roleName=${roleName }&id=${id}';" />
                                <input type="button" value="删除" class="btn_delete" onclick="deleteAdmin(${id});" />
                            </td>
                        </tr>
                     </s:iterator> 
                    </table>
                </div>
                <!--分页-->
                <div id="pages">
        	        <s:if test="page>1">
        	        <a href="?module=${module }&roleName=${roleName }&page=${page-1}">上一页</a>
        	        </s:if><s:else><a>上一页</a></s:else>
        	        <s:iterator begin="1" end="pageCount" var="i">
                    <a href="?module=${module }&roleName=${roleName }&page=${i}" <s:if test="page==#i">class="current_page"</s:if> >${i}</a>
                 </s:iterator>
                 <s:if test="page<pageCount">
        	        <a href="?module=${module }&roleName=${roleName }&page=${page+1}">下一页</a>
        	        </s:if><s:else><a>下一页</a></s:else>
                </div>                    
            </s:form>
        </div>
       
        <%@include file="../common/bottom.jsp"%> 
    </body>
</html>
